<template>
    <div class="video_list">
      
        <div class="list_title">
            <h3>最新MV推荐</h3>
            <i class="iconfont icon-gengduo" @click="mv_all"></i>
        </div>
        
        <ul class="mv_lists">
            <li v-if="id<moreNum" v-for="(item, id) in mv_box" :key="id">
                  <div class="mv_img" @click="watchMv(item.videoId,item)">
                      <img :src="item.bigHeadImg" alt="">
                  </div>
                  <p class="song_name">{{item.title}}</p>
                  <p class="singer">{{item.artists[0].name}}</p>
            </li>
        </ul>
        <div class="more" @click="moreBtn">
          <p><i class="iconfont icon-icon04"></i></p>
          <p>加载更多</p>
        </div>
    </div>
</template>
<script>

import jsonp from "jsonp";
export default {
  name: "video_list",
  data() {
    return {
      mv_box: JSON.parse(sessionStorage.getItem("mv_box")),
      moreNum: "4"
    };
  },
  computed: { 
  },
  methods: {
    watchMv(videoId, item) {
      this.$router.push("/Mv_play/" + videoId);
      this.$store.commit("agemv", item);
      this.$store.commit("ageisplayicon", false); //媒体播放冲突处理

    },
    moreBtn() {
      this.moreNum = +this.moreNum + 4;
    },
//弹出所有mv
    mv_all() {
      this.$router.push('/Mv_list_all');
      this.$store.commit('changeIsplayMap',true);
    }
  },
  components: {

  },
  created() {
    jsonp(
      "http://uapi.yinyuetai.com/i/mv/favorite-list?uid=56988303&order=new&gid=&page=1&pageSize=3000",
      null,
      (err, res) => {
        if (!err) {
          this.mv_box = res.videos;
          console.log(res);
          
          sessionStorage.setItem("mv_box", JSON.stringify(res.videos));
        } else {
          console.log(err);
        }
      }
    );
  }
};
</script>
<style lang="scss" scoped>
.video_list {
  width: 100%;
  margin-top: 0.1rem;
  background: #fff;
  padding-top: 0.6rem;
  margin-bottom: 1.7rem;
  
  .list_title {
    width: 100%;
    position: relative;
    text-align: center;
    height: 1rem;
    h3 {
      font-size: 15px;
      line-height: 1rem;
    }
    i {
      position: absolute;
      top: 0rem;
      right: 0.2rem;
      font-size: 0.6rem;
      line-height: 1rem;
    }
  }
  // 视频列表
  .mv_lists {
    width: 100%;
    overflow: hidden;
    margin-top: 0.3rem;
    li {
      float: left;
      width: 49.5%;
      overflow: hidden;
      .mv_img {
        width: 100%;
        height: 3rem;
        background: paleturquoise;
        overflow: hidden;
        img {
          width: 100%;
        }
      }
      > p {
        margin-left: 0.2rem;
        margin-top: 0.1rem;
        line-height: 0.6rem;
      }
      .song_name {
        font-size: 12px;
        overflow: hidden;
        white-space: nowrap; /*强制显示一行*/
        text-overflow: ellipsis; /*溢出文字省略号处理*/
        width: 150px;
        // display: -webkit-box;
      }
      .singer {
        font-size: 10px;
        color: #aaaaaa;
      }
    }
    li:nth-of-type(2n + 2) {
      float: right;
    }
  }
  .more {
    width: 100%;
    background: #fff;
    padding: 0.3rem 0;
    border-top: 1px solid #f1f1f1;
    p {
      text-align: center;
      font-size: 0.2rem;
      color: #a4a4a4;
    }
  }

  .Mv_list_all{
    position: absolute;
    top: 0;
    left: 0;
    z-index: 100;
    transform: translateY(-100%);
  }
}
</style>
